package com.kn.order.untils;

import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;

/**
 * @author zhoudf
 * @create 2021-03-05 11:10
 */
public class CopyBean{
    public static <T,S> T copyBean(Supplier<T> target,S source){
        T t =target.get();
        BeanUtils.copyProperties(source,t);
        return t;
    }
    public static <T,S> List<T> copyBean(Supplier<T> target,List<S> source) {
     return    source.stream().map(s -> CopyBean.copyBean(target, s))
                .collect(Collectors.toList());
    }
}
